using EPlantApp.SignalR;
using EPlantApp.SignalR.Models;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;

namespace EPlantApp.WebApi.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class DeviceStatusController : ControllerBase
    {
        private readonly ILogger<DeviceStatusController> _logger;
        private readonly IHubContext<DeviceStatusHub> _hubContext;

        public DeviceStatusController(ILogger<DeviceStatusController> logger, IHubContext<DeviceStatusHub> hubContext)
        {
            _logger = logger;
            _hubContext = hubContext;
        }

        [HttpGet(Name = "PushMsg")]
        public async Task<IActionResult> PushMsg([FromQuery]string content)
        {
            await _hubContext.Clients.All.SendAsync("ShowMsg", new DeviceInfo { DeviceId = content, Name = "1", ProductionLine = "1", Workshop = "1" });
            return Ok();
        }
    }
}
